package com.qf.industry.controller;

import com.qf.core.dto.PageDto;
import com.qf.core.vo.PageResult;
import com.qf.core.vo.R;
import com.qf.industry.entity.Industry;
import com.qf.industry.service.IndustryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 行业表 前端控制器
 * </p>
 *
 * @author wu
 * @since 2023-10-27
 */
@RestController
@CrossOrigin
@RequestMapping("industry")
public class IndustryController {

    @Autowired
    private IndustryService industryService;

    @GetMapping("all")
    public R findAll(){
        return R.ok(industryService.list(),"");
    }

    @PostMapping("add")
    public R add(@RequestBody Industry industry){
        return industryService.add(industry);
    }

    @PostMapping("/update")
    public R update(@RequestBody Industry industry){
        return R.ok(industryService.updateById(industry));
    }

    @PostMapping("delete")
    public R delete(@RequestBody Industry industry){
        return R.ok(industryService.deleteById(industry));
    }

    @PostMapping("page")
    public PageResult<Industry> page(@RequestBody PageDto<Industry> pageDto){

        return industryService.page(pageDto);
    }

}
